function EditOrderTask(container, item, callbackFunc, options) {
  this._container = container;
  this._item = item;
  this._callbackFunc = callbackFunc;

  this._parent = (options && options.parent) ? options.parent : null;
  this._index = (options && options.index) ? options.index : null;
  
  if (!this._item) {
    this._item = OrderTask.instance();
  }
  
  this._createElements();
};

EditOrderTask.prototype._createElements = function() {
  var unique, _self = this;

  DOMUtils.removeChildElements(this._container);
  
  unique = MiscUtils.unique();
  new EditOrderTaskGui(unique, this._container, this._item);
  
  this._gui = { date: document.getElementById(unique + '_date'),
                remove: document.getElementById(unique + '_remove'),
                addPHO: document.getElementById(unique + '_add_photographer'),
                addVDO: document.getElementById(unique + '_add_videographer'),
                addMKP: document.getElementById(unique + '_add_makeup')
              }

  this._gui.remove.onclick = function() { _self._parent.tasks.splice(this._index, 1);
                                          _self._callbackFunc();
                                        };
  
  this._gui.addPHO.onclick = function() { var user = OrderTaskUser.instance();
                                          user.status.date = _self._item.date;
                                          user.status.state = 1;
                                          user.status.model = '{{$smarty.const.MODEL_NAME_USER_PHOTOGRAPHER|escape:javascript}}';
                                          _self._item.photographers[_self._item.photographers.length] = user;
                                          _self._callbackFunc();
                                        };
  this._gui.addVDO.onclick = function() { var user = OrderTaskUser.instance();
                                          user.status.date = _self._item.date;
                                          user.status.state = 1;
                                          user.status.model = '{{$smarty.const.MODEL_NAME_USER_VIDEOGRAPHER|escape:javascript}}';
                                          _self._item.videographers[_self._item.videographers.length] = user;
                                          _self._callbackFunc();
                                        };
  this._gui.addMKP.onclick = function() { var user = OrderTaskUser.instance();
                                          user.status.date = _self._item.date;
                                          user.type = MakeupType.array()[0];
                                          user.status.state = 1;
                                          user.status.model = '{{$smarty.const.MODEL_NAME_USER_MAKEUP|escape:javascript}}';
                                          _self._item.makeups[_self._item.makeups.length] = user;
                                          _self._callbackFunc();
                                        };
  for (var i = 0, il = this._item.photographers.length; i < il; i++) {
    var user = this._item.photographers[i];
    this._guiP = { estimates: document.getElementById(unique + '_' + i + '_photographer_hours'),
                   extras: document.getElementById(unique + '_' + i + '_photographer_extraHours'),
                   travel: document.getElementById(unique + '_' + i + '_photographer_travel'),
                   hoursLess: document.getElementById('photo' + unique + '_' + i + '1'),
                   hoursMore: document.getElementById('photo' + unique + '_' + i + '2'),
                   extrasLess: document.getElementById('photo' + unique + '_' + i + '3'),
                   extrasMore: document.getElementById('photo' + unique + '_' + i + '4'),
                   travelLess: document.getElementById('photo' + unique + '_' + i + '5'),
                   travelMore: document.getElementById('photo' + unique + '_' + i + '6'),
                   remvoe: document.getElementById(unique + '_' + i + '_photographer_remove')
                 };
    this._guiP.hoursLess._user = user;
    this._guiP.hoursMore._user = user;
    this._guiP.extrasLess._user = user;
    this._guiP.extrasMore._user = user;
    this._guiP.travelLess._user = user;
    this._guiP.travelMore._user = user;
    this._guiP.remvoe._index = i;
    
    this._guiP.hoursLess.onclick = function() {};
    this._guiP.hoursMore.onclick = function() {};
    this._guiP.extrasLess.onclick = function() {};
    this._guiP.extrasMore.onclick = function() {};
    this._guiP.travelLess.onclick = function() {};
    this._guiP.travelMore.onclick = function() {};

    this._guiP.remvoe.onclick = function() { _self._item.photographers.splice(this._index, 1);
                                             _self._callbackFunc();
                                           };
  }
  
  for (var j = 0, jl = this._item.videographers.length; j < jl; j++) {
    var user = this._item.videographers[j];
    this._guiV = { estimates: document.getElementById(unique + '_' + j + '_videographer_hours'),
                   extras: document.getElementById(unique + '_' + j + '_videographer_extraHours'),
                   travel: document.getElementById(unique + '_' + j + '_videographer_travel'),
                   hoursLess: document.getElementById('video' + unique + '_' + j + '1'),
                   hoursMore: document.getElementById('video' + unique + '_' + j + '2'),
                   extrasLess: document.getElementById('video' + unique + '_' + j + '3'),
                   extrasMore: document.getElementById('video' + unique + '_' + j + '4'),
                   travelLess: document.getElementById('video' + unique + '_' + j + '5'),
                   travelMore: document.getElementById('video' + unique + '_' + j + '6'),
                   remvoe: document.getElementById(unique + '_' + j + '_videographer_remove')
                 };
    this._guiV.hoursLess._user = user;
    this._guiV.hoursMore._user = user;
    this._guiV.extrasLess._user = user;
    this._guiV.extrasMore._user = user;
    this._guiV.travelLess._user = user;
    this._guiV.travelMore._user = user;
    this._guiV.remvoe._index = j;
    
    this._guiV.hoursLess.onclick = function() {};
    this._guiV.hoursMore.onclick = function() {};
    this._guiV.extrasLess.onclick = function() {};
    this._guiV.extrasMore.onclick = function() {};
    this._guiV.travelLess.onclick = function() {};
    this._guiV.travelMore.onclick = function() {};
    
    this._guiV.remvoe.onclick = function() { _self._item.videographers.splice(this._index, 1);
                                             _self._callbackFunc();
                                           };
  }
  
  for (var i = 0, il = this._item.makeups.length; i < il; i++) {
    var user = this._item.makeups[i];
    var gui = { sample: document.getElementById(unique + '_' + i + '_makeup_sample_select'),
                remvoe: document.getElementById(unique + '_' + i + '_makeup_remove')
              };
    gui.sample._user = user;
    gui.remvoe._index = i;
    
    for (var j = 0, jl = MakeupType.array().length; j < jl; j++) {
      var type = MakeupType.array()[j]
      var option = document.getElementById(unique + '_' + i + '_' + j + '_makeup_sample_option');
      option._type = type;
    }
    
    gui.sample.onchange = function() { this._user.type = this.options[this.selectedIndex]._type;
                                       _self._callbackFunc();
                                     };
    gui.remvoe.onclick = function() { _self._item.makeups.splice(this._index, 1);
                                      _self._callbackFunc();
                                    };
  }
};